module enqueueArbiter8 (
    input wire queue_en_1,
    input wire [5:0] data_priority_1,
    input wire queue_en_2,
    input wire [5:0] data_priority_2,
    input wire queue_en_3,
    input wire [5:0] data_priority_3,
    input wire queue_en_4,
    input wire [5:0] data_priority_4,
    input wire queue_en_5,
    input wire [5:0] data_priority_5,
    input wire queue_en_6,
    input wire [5:0] data_priority_6,
    input wire queue_en_7,
    input wire [5:0] data_priority_7,
    input wire queue_en_8,
    input wire [5:0] data_priority_8,
    output wire [7:0] queue_arbitration
);

    wire [27:0] bigger;

    //构建数组
    assign bigger[0] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_2;  //0-1
    assign bigger[1] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_3;  //0-2
    assign bigger[2] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_4;  //0-3
    assign bigger[3] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_5;  //0-4
    assign bigger[4] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_6;  //0-5
    assign bigger[5] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_7;  //0-6
    assign bigger[6] = queue_en_1==0 ? 0 : data_priority_1 >= data_priority_8;  //0-7
    assign bigger[7] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_3;  //1-2
    assign bigger[8] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_4;  //1-3
    assign bigger[9] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_5;  //1-4
    assign bigger[10] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_6;  //1-5
    assign bigger[11] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_7;  //1-6
    assign bigger[12] = queue_en_2==0 ? 0 : data_priority_2 >= data_priority_8;  //1-7
    assign bigger[13] = queue_en_3==0 ? 0 : data_priority_3 >= data_priority_4;  //2-3
    assign bigger[14] = queue_en_3==0 ? 0 : data_priority_3 >= data_priority_5;  //2-4
    assign bigger[15] = queue_en_3==0 ? 0 : data_priority_3 >= data_priority_6;  //2-5
    assign bigger[16] = queue_en_3==0 ? 0 : data_priority_3 >= data_priority_7;  //2-6
    assign bigger[17] = queue_en_3==0 ? 0 : data_priority_3 >= data_priority_8;  //2-7
    assign bigger[18] = queue_en_4==0 ? 0 : data_priority_4 >= data_priority_5;  //3-4
    assign bigger[19] = queue_en_4==0 ? 0 : data_priority_4 >= data_priority_6;  //3-5
    assign bigger[20] = queue_en_4==0 ? 0 : data_priority_4 >= data_priority_7;  //3-6
    assign bigger[21] = queue_en_4==0 ? 0 : data_priority_4 >= data_priority_8;  //3-7
    assign bigger[22] = queue_en_5==0 ? 0 : data_priority_5 >= data_priority_6;  //4-5
    assign bigger[23] = queue_en_5==0 ? 0 : data_priority_5 >= data_priority_7;  //4-6
    assign bigger[24] = queue_en_5==0 ? 0 : data_priority_5 >= data_priority_8;  //4-7
    assign bigger[25] = queue_en_6==0 ? 0 : data_priority_6 >= data_priority_7;  //5-6
    assign bigger[26] = queue_en_6==0 ? 0 : data_priority_6 >= data_priority_8;  //5-7
    assign bigger[27] = queue_en_7==0 ? 0 : data_priority_7 >= data_priority_8;  //6-7

    //根据优先级的值选择最大的优先级
    assign queue_arbitration[0] = queue_en_1 & bigger[0] & bigger[1] & bigger[2] & bigger[3] & bigger[4] & bigger[5] & bigger[6];
    assign queue_arbitration[1] = queue_en_2 & ~bigger[0] & bigger[7] & bigger[8] & bigger[9] & bigger[10] & bigger[11] & bigger[12];
    assign queue_arbitration[2] = queue_en_3 & ~bigger[1] & ~bigger[7] & bigger[13] & bigger[14] & bigger[15] & bigger[16] & bigger[17];
    assign queue_arbitration[3] = queue_en_4 & ~bigger[2] & ~bigger[8] & ~bigger[13] & bigger[18] & bigger[19] & bigger[20] & bigger[21];
    assign queue_arbitration[4] = queue_en_5 & ~bigger[3] & ~bigger[9] & ~bigger[14] & ~bigger[18] & bigger[22] & bigger[23] & bigger[24];
    assign queue_arbitration[5] = queue_en_6 & ~bigger[4] & ~bigger[10] & ~bigger[15] & ~bigger[19] & ~bigger[22] & bigger[25] & bigger[26];
    assign queue_arbitration[6] = queue_en_7 & ~bigger[5] & ~bigger[11] & ~bigger[16] & ~bigger[20] & ~bigger[23] & ~bigger[25] & bigger[27];
    assign queue_arbitration[7] = queue_en_8 & ~bigger[6] & ~bigger[12] & ~bigger[17] & ~bigger[21] & ~bigger[24] & ~bigger[26] & ~bigger[27];

endmodule